//
//  TYZTabBarController.m
//  TYZ_SC
//
//  Created by 李贤立 on 2017/12/12.
//  Copyright © 2017年 Capfer. All rights reserved.
//

#import "TYZTabBarController.h"
#import "TYZCustomerViewController.h"
#import "TYZWorkbenchViewController.h"
#import "TYZWorkcircleViewController.h"
#import "TYZMoreViewController.h"
@interface TYZTabBarController ()
/**
 *  itemArray
 */
@property(nonatomic, strong) NSArray<UITabBarItem *> *itemArray;
@end

@implementation TYZTabBarController

- (void)viewWillLayoutSubviews{
    CGRect tabFrame = self.tabBar.frame; //self.TabBar is IBOutlet of your TabBar
    tabFrame.size.height = Value_TabBarControllerHeight;
    tabFrame.origin.y = self.view.frame.size.height - Value_TabBarControllerHeight;
    self.tabBar.frame = tabFrame;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    TYZWorkbenchViewController      *vc1 =  [[TYZWorkbenchViewController alloc] init];
    TYZCustomerViewController       *vc2 =  [[TYZCustomerViewController alloc] init];
    TYZWorkcircleViewController     *vc3 =  [[TYZWorkcircleViewController alloc] init];
    TYZMoreViewController           *vc4 =  [[TYZMoreViewController alloc] init];
    self.viewControllers = @[vc1, vc2, vc3, vc4];
    [self.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        obj.tabBarItem = self.itemArray[idx];
    }];
    self.tabBar.tintColor = TYZBlueColor;
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:animated];
//    self.navigationController.navigationBarHidden = NO;
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    self.navigationController.navigationBarHidden = NO;
}

- (NSArray<UITabBarItem *> *)itemArray {
    if (_itemArray == nil) {
        UITabBarItem *item1 = [[UITabBarItem alloc] initWithTitle:@"工作台" image:[UIImage imageNamed:@"Tab_01"] selectedImage:[UIImage imageNamed:@"Tab_02"]];
        UITabBarItem *item2 = [[UITabBarItem alloc] initWithTitle:@"客户" image:[UIImage imageNamed:@"Tab_11"] selectedImage:[UIImage imageNamed:@"Tab_12"]];
        UITabBarItem *item3 = [[UITabBarItem alloc] initWithTitle:@"工作圈" image:[UIImage imageNamed:@"Tab_21"] selectedImage:[UIImage imageNamed:@"Tab_22"]];
        UITabBarItem *item4 = [[UITabBarItem alloc] initWithTitle:@"更多" image:[UIImage imageNamed:@"Tab_31"] selectedImage:[UIImage imageNamed:@"Tab_32"]];
        _itemArray = @[item1, item2, item3, item4];
    }
    return _itemArray;
}
@end
